<?php
namespace app\admin\controller;
use app\admin\common\Base;
use think\Db;
class Daylog extends Base
{
    public function index()
    {

        $data=$this->request->param();
        if(isset($data['ajax'])&&$data['ajax']==1){
            $map='';
            //$map=$this->search($data);
            $page=isset($data['page'])?$data['page']:1;
            $page=intval($page);
            $limit=isset($data['rows'])?$data['rows']:10;
            $limit=intval($limit);
            $start=$limit*($page-1);
            if($map==''){
                $list =Db::name('admin_log')->order('addtime desc,id desc')->limit($start,$limit)->select();
                $count =Db::name('admin_log')->order('addtime desc,id desc')->count();
              
            }else{
                $list =Db::name('admin_log')->order('addime desc,id desc')->limit($start,$limit)->select();
                 $count =Db::name('admin_log')->order('addtime desc,id desc')->count();
            }
            foreach ($list as $key => &$val) {
                $val['addtime']=date('Y-m-d',$val['addtime']); 
                $val['username']=Db::name('admin')->where('id',$val['admin_id'])->value('username');      
            }

                 
            return $this->json_data($count,$list); 

        }
        return $this->fetch('index');
    }

}
